package com.aptech.servlet;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.Enumeration;
import java.util.Locale;
import java.util.ResourceBundle;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class I18NDemo extends HttpServlet {
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        ResourceBundle bundle = ResourceBundle.getBundle(
                "com.aptech.bundle.Resource", new Locale("vn", "VN"));
        Enumeration keys = bundle.getKeys();
        PrintWriter out = response.getWriter();
        while (keys.hasMoreElements()) {
            String key = (String) keys.nextElement();
            System.out.println("key:" + key);
            System.out.println("value:" + bundle.getString(key));
        }
        request.setAttribute("message", bundle);

        out.println("Title:" + bundle.getString("title"));
        bundle = ResourceBundle.getBundle(
                "com.aptech.bundle.Resource", new Locale("en", "US"));
        out.println("Title:" + bundle.getString("title"));
    }
}
